//Eg3-21.cpp
#include <iostream>
using namespace std;
class Tdate{
private:
    int yy,mm,dd;
public:
    Tdate(int y=2006,int m=01,int d=01);
    Tdate &setYear(int year);
    Tdate &setMonth(int month);
    Tdate *setDay(int day);
    Tdate setDate(int y,int m,int d);
    void display();
};
Tdate::Tdate(int y,int m,int d){ yy=y;mm=m;dd=d;}
Tdate& Tdate::setYear(int year){
    yy=year;
    return *this;
}
Tdate&  Tdate::setMonth(int month){
    mm=month;
    return *this;
}

Tdate*  Tdate::setDay(int day){
    dd=day;
    return this;
}
Tdate  Tdate::setDate(int y,int m,int d){
    yy=y; mm=m; dd=d;
    return *this;
}
void Tdate::display(){
    cout<<"addres is: "<<this<<"\t"<<yy<<":"<<mm<<":"<<dd<<endl;
}
void main(){
    Tdate d1,d2;										//L1
    cout<<"d1 ";  d1.display();						//L2
    cout<<"d2 ";  d2.display();						//L3
    d1.setYear(2007).setMonth(03).setDay(30);		//L4
    cout<<"d1 ";  d1.display();						//L5
    d1.setDate(2000,01,10).setDay(30);				//L6
    cout<<"d1 ";  d1.display();						//L7
    Tdate *p;										//L8
    p=d1.setDay(21);									//L9
    cout<<" p ";										//L10
    p->display();									//L11
    Tdate d3=d2.setYear(2006).setMonth(4);			//L12
    cout<<"d3 "; d3.display();						//L13
    d1.setYear(2007).setMonth(03)=d3;				//L14
    cout<<"d1 ";  d1.display();						//L15
}

